/*
 * Clock.cpp
 *
 *  Created on: 2012-5-18
 *      Author: WuyaMony
 */

#include "Clock.h"

namespace my {
int Clock::_timeCost = 0;
Clock::Clock(deque<int> &Data, deque<int> &ABdata, ArithmeticUnit &arithunit) :
		_data(Data), _ABdata(ABdata), _arithunit(arithunit) {
}

void Clock::Tick() {
	_timeCost++;
	cout << "tick: " << _timeCost << endl;
	if(_data.size()>=2){
		_arithunit.addTask(_data.front(),
				(_data.pop_front(), _data.front()), ArithmeticUnit::add);
		_data.pop_front();
	}else if(_ABdata.size()>=2){
		_arithunit.addTask(_ABdata.front(),
				(_ABdata.pop_front(), _ABdata.front()), ArithmeticUnit::mul);
		_ABdata.pop_front();
	}
}

} /* namespace my */
